package com.stlm2.controller.informs;

import com.stlm2.dems.informs.entity.InformsState;
import com.stlm2.dems.informs.service.InformsService;

import com.stlm2.util.codecontent.CodeContent;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.annotation.Resource;

/**
 * Created by ZLQ on 2017/5/30.
 */
@Controller
@RequestMapping("/InformsC")
public class InformsController {
    @Resource
    private InformsService informsService;

    /*
*ZLQ
*查询新闻列表(前台)
 */
    @ResponseBody
    @RequestMapping(value="/getInformsList.json",produces="application/json;charset=UTF-8")
    public  String getInformsList(String companyCode,ModelMap modelMap , String page){
        String data=null;
        try {
            data=informsService.getInformsList(modelMap,page, InformsState.Valid);
        }catch (Exception e){
            e.printStackTrace();
            return  CodeContent.getModelByCode(0,"查询新闻列表失败",data);
        }
        return  data;
    }
    /*
*ZLQ
* 根据ID查询新闻详情(前台)
* Id：新闻ID
*/
    @ResponseBody
    @RequestMapping(value="/getDetails.json",produces="application/json;charset=UTF-8")
    public String getDetails (String companyCode,ModelMap model,String Id){
        String data=null;
        try {
            data=informsService.getDetails(model,Id);
        }catch (Exception e){
            e.printStackTrace();
            return  CodeContent.getModelByCode(0,"查询新闻详情失败",data);
        }
        return data;
    }

    /**
     * 六条滚动的新闻
     * ffl
     * @return
     */

    @ResponseBody
    @RequestMapping(value="/getSixInforms.json",produces="application/json;charset=UTF-8")
    public  String getSixSortByTime(String companyCode){
      String data="";
            data=informsService.getSixSortByTime();
        return data;

    }
}
